#include <QtPlugin>
#include <QString>
#include <QWidget>
#include <QGridLayout>
#include <QLabel>
#include <QSlider>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QCheckBox>

#include <opencv/cv.h>
#include <opencv/highgui.h>

#include "QCVModuleInterface.h"
#include "QCVModuleHandlerInterface.h"

#include "CVStip.h"//module independant de qt

#ifndef MODULESTIP_H
#define MODULESTIP_H

#define RESOLUTION 1000.0
#define MAXIMUM 5.0

/**
@class ModuleSTIP
@brief Module de détection de points d'interêts spatio-temporels
*/

class ModuleSTIP:public QObject,QCVModuleInterface
{
	Q_OBJECT
	Q_INTERFACES(QCVModuleInterface)
	
	public:

		/**
		@brief Voir QCVModuleInterface
		*/
		void init(QCVModuleHandlerInterface * parent);
		
		/**
		@brief Voir QCVModuleInterface
		*/
		void free();

		/**
		@brief Voir QCVModuleInterface
		*/
		cv::Mat & process();

		/**
		@brief Voir QCVModuleInterface
		*/
		void setInput(int n,const cv::Mat & m);

		/**
		@brief Voir QCVModuleInterface
		*/
		QWidget* widget();

		/**
		@brief Voir QCVModuleInterface
		*/
		QString getName();
		
		/**
		@brief Voir QCVModuleInterface
		*/
		int nbInputs();

		/**
		@brief Voir QCVModuleInterface
		*/		
		QString help(int id);
		
		bool setParams(QString params);
    QString getParams();

		QCVModuleInterface * clone();

	private slots:    
		void setDimX(int X);
		void setDimY(int Y);
		void setDimT(int T);
		
		void setK(int K);
		void setSigmaS(int SigmaS);
		void setSigmaT(int SigmaT);
		void setThreshold(int Threshold);
		
		void setK(double K);
		void setSigmaS(double SigmaS);
		void setSigmaT(double SigmaT);
		void setThreshold(double Threshold);
  
		void setOutput(int id);

	private:
		//Elements de l'IHM

		cv::Mat m_cut;

		QCheckBox * use_mask;
		
		QWidget * win;

		QGridLayout * layout;

		QLabel * labelParamK;
		QLabel * labelParamSigmaS;
		QLabel * labelParamSigmaT;
		QLabel * labelParamDimX;
		QLabel * labelParamDimY;
		QLabel * labelParamDimT;
		QLabel * labelParamThreshold;

		QSlider * slideParamK;
		QSlider * slideParamSigmaS;
		QSlider * slideParamSigmaT;
		QSlider * slideParamThreshold;

		QDoubleSpinBox * spinBoxParamK;
		QDoubleSpinBox * spinBoxParamSigmaS;
		QDoubleSpinBox * spinBoxParamSigmaT;
		QDoubleSpinBox * spinBoxParamThreshold;

		QSpinBox * spinBoxParamDimX;
		QSpinBox * spinBoxParamDimY;
		QSpinBox * spinBoxParamDimT;

		QComboBox * select_output;

		QCVModuleHandlerInterface * parent;

		CVStip stip;
};                    

#endif
